package abstracttransaction

import (
	Database "salarypayment-case/DataBase"
	"salarypayment-case/Model"
	"salarypayment-case/modelimplementation"
)

type AddEmployeeTransaction struct {
	ClassificationTransaction
	itsEmpid   int
	itsName    string
	itsAddress string
}

func CreateAddEmployeeTransaction(empid int, name string, address string) *AddEmployeeTransaction {
	return &AddEmployeeTransaction{itsEmpid: empid, itsName: name, itsAddress: address}
}

func (ae *AddEmployeeTransaction) Execute() {
	pc := ae.GetClassification()
	ps := ae.GetSchedule()
	pm := modelimplementation.HoldMethod{}
	e := Model.CreateEmployee(ae.itsEmpid, ae.itsName, ae.itsAddress)
	e.SetClassification(pc)
	e.SetSchedule(ps)
	e.SetMethod(&pm)
	Database.PayrollDatabases.AddEmployee(e.GetEmpid(),e)
}
